package com.tommy.ddp.disposeHandler.special
{
	import com.tommy.ddp.GridDataManager;
	import com.tommy.ddp.MainManager;
	import com.tommy.ddp.box.DdpBox;
	import com.tommy.ddp.definition.BoxExeType;
	import com.tommy.ddp.disposeHandler.IDisposeHandler;
	import com.tommy.ddp.manager.DisposeBoxManager;
	import com.tommy.ddp.swapHandle.DisposeVoHandler;
	import com.tommy.ddp.swapHandle.SubDisposeVo;
	
	import flash.utils.setTimeout;

	/**
	 * 消除某个特定颜色
	 * @author hongxuan
	 * 
	 */	
	public class DisposeAllColorHandler implements ISpecialDisposeHandler
	{
		private var _color:uint;
		
		public function DisposeAllColorHandler()
		{
		}
		
		public function dispose(vect:Vector.<DdpBox>,n:Number):void
		{
			for each(var i:DdpBox in vect)
			{
				if(i.exeType != BoxExeType.SUPER_BOOM)
				{
					_color = i.colorType;
				}
				i.dispose();
				GridDataManager.removeBox(i);
			}
			MainManager.game.tips = "清除某种颜色的所有的糖果";
			setTimeout(_dispose,n);
		}
		
		private function _dispose():void
		{
			var vect:Vector.<DdpBox> = new Vector.<DdpBox>();
			var arr:Array = GridDataManager.allBox;
			for each(var i:DdpBox in arr)
			{
				if(i.colorType == _color)
					vect.push(i);
			}
			
			var vo:SubDisposeVo = new SubDisposeVo();
			vo.vect = vect;
			
			DisposeBoxManager.disposeSubVo(vo);
		}
	}
}